﻿using Microsoft.Practices.Unity;
using RIBA.DomainServices;
using Riba.MVVMSL;

namespace RIBA.VMLocator
{
	public class ViewModelLocator
	{
		private static IUnityContainer _container;

		public Indexer Find { get; private set; }

		public ViewModelLocator()
		{
			_container = new UnityContainer();

			if (ViewModelBase.IsInDesignTool)
				_container.RegisterType<IDomainServiceRIBA, DomainServiceRIBAMock>
					(new ContainerControlledLifetimeManager());  //Singleton
			else
				_container.RegisterType<IDomainServiceRIBA, DomainServiceRIBALive>
					(new ContainerControlledLifetimeManager());  //Singleton

			Find = new Indexer { UnityContainer = _container };
		}
	}
}
